package com.moneyanalyzer;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.moneyanalyzer.model.Category;

public class CategoryAdapter extends BaseAdapter {
	private Context context;
	List<Category> categoryList;
    
	public CategoryAdapter(Context context, List<Category> categoryList){
		this.context = context;
		this.categoryList = categoryList;
	}

	@Override
	public int getCount() {
		return categoryList.size();
	}

	@Override
	public Object getItem(int position) {
		return categoryList.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		Category category = categoryList.get(position);
		LayoutInflater inflater = (LayoutInflater)
	            context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		View view = inflater.inflate(R.layout.item_list_category, null);
		TextView categoryName = (TextView)view.findViewById(R.id.textCategory);
		categoryName.setText(category.getId()+": "+category.getName());
		return view;
	}

}
